package com.hmall.domain.doc;

import com.baomidou.mybatisplus.annotation.TableField;
import com.hmall.domain.pojo.Item;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 商品es中的文档对象
 *
 * @Author XiaoJiangShi
 * @Date 2022/8/10 15:18
 * @Blog blog.XiaoJiangShi.net/996.mba
 * @Description:
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ItemDoc implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * 商品id
     */
    private Long id;
    /**
     * 商品名称
     */
    private String name;
    /**
     * 价格（分）
     */
    private Long price;
    /**
     * 商品图片
     */
    private String image;
    /**
     * 分类名称
     */
    private String category;
    /**
     * 品牌名称
     */
    private String brand;

    /**
     * 销量
     */
    private Integer sold;

    /**
     * 评论数
     */
    private Integer commentCount;

    /**
     * 商品广告状态 false 未打广告 ture 已打广告
     */
    @TableField("isAD")
    private Boolean isAD;

    private List<String> suggestion;

    public ItemDoc(Item item) {
        this.id = item.getId();
        this.name = item.getName();
        this.price = item.getPrice();
        this.image = item.getImage();
        this.category = item.getCategory();
        this.brand = item.getBrand();
        this.sold = item.getSold();
        this.commentCount = item.getCommentCount();
        this.isAD = item.getIsAD();

        this.suggestion = new ArrayList<>();
        this.suggestion.add(brand);
        this.suggestion.add(category);
    }
}

